<html lang="en" class=" ext-strict">

  <!--HEAD-->
  <head>

  <title>Proyecto David</title>

    <%= render 'layouts/javascript_estilos' %>
    <%= csrf_meta_tags %>

 </head>

  <!--BODY-->
  <body id="ext-gen6" class=" ext-safari has_project_nav " data-spy="scroll" data-target=".subnav" data-offset="50">

  <div id="sg_grid_heading_proxy" style="position: absolute; visibility: hidden; cursor: move; border: 2px solid rgb(170, 170, 170); z-index: 999; "></div>
    <div id="ygddfdiv" style="position: absolute; visibility: hidden; cursor: move; border: 2px solid rgb(170, 170, 170); z-index: 999; ">
    </div>

    <!-- Barra de navegacion superior
    ================================================== -->
    <div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
         </a>
         <a class="brand" href="#"><%=t('.home')%>
         </a>
          <div class="nav-collapse collapse">
             <ul class="nav">
              <% if can? :manage, Proyecto %>
               <li ><%= link_to t('.menu3_0'), proyectos_path %></li>
              <% end %>
              <% if can? :manage, Recurso %>
               <li><%= link_to t('.menu3_1'), recursos_path %></li>
              <% end %>
              <% if can? :manage, Usuario %>
               <li><%= link_to t('.config_6'), usuarios_path %></li>
              <% end %>
              <% if can? :manage, Artefacto %>
               <li><%= link_to t('.menu3_3'), artefactos_path %></li>
              <% end %>
              <% if can? :manage, Rol %>
               <li class="dropdown active">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= t('.config')%><b class="caret"></b></a>
                  <ul class="dropdown-menu">
                 <% if can? :manage, Rol %>
                   <%= link_to t('.config_1'), rols_path %>
                 <% end %>
                 <% if can? :manage, TipoRecurso %>
                  <%= link_to t('.config_3'), tipo_recursos_path %>
                 <% end %>
                 <% if can? :manage, TipoArtefacto %>
                  <%= link_to t('.config_5'), tipo_artefactos_path %>
                 <% end %>
                 <% if can? :manage, TipoDeposito %>
                  <%= link_to t('.config_7'), tipo_depositos_path %>
                 <% end %>
                 <% if can? :manage, TipoPlantilla %>
                  <%= link_to t('.config_4'), tipo_plantillas_path %>
                 <% end %>
                 <% if can? :manage, Organizacion %>
                   <%= link_to t('.config_2'), organizacions_path %>
                 <% end %>
                 <% if can? :manage, Plantilla %>
                   <!-- <%= link_to t('.config_0'), depositos_path %>   -->
                   <%= link_to t('.menu3_2'), plantillas_path %>
                 <% end %>
                 </ul>
               </li>
               <% end %>
             </ul>
             <ul class="nav pull-right" style="width: 40%">
              <li class="divider-vertical"></li>
               <div id="user_nav">
                 <%= javascript_include_tag :defaults %>

                 <script type="text/javascript">
                    $(document).ready(function() {
                        $('#user_nivel_acceso').change(function () {
                            var nivel = $("#user_nivel_acceso option:selected").val();
                            if(nivel == "1")
                                document.location = "<%= request.protocol + request.host_with_port %>/proyectos";
                            else if(nivel == 2)
                                document.location = "<%= request.protocol + request.host_with_port %>/proyectos";
                            else
                                document.location = "<%= request.protocol + request.host_with_port %>/tarea_participantes";
                        });
                    });
                 </script>

                 <% if user_signed_in? %>
                     <%= current_user.email %>.

                     <%
                        @usr_roles = RolesUsers.find_all_by_user_id(current_user.id);
                        if(@usr_roles.count() > 1) then
                     %>
                       <select id="user_nivel_acceso" name="user_nivel_acceso" style="width: 150px;height: 25px;">
                       <option value="" selected="true"><%= t('change_workspace') %></option>
                     <%
                        @usr_roles.each do |usr_rol|
                     %>
                        <option value="<%= usr_rol.role_id%>">
                          <%= case usr_rol.role_id
                            when 1
                              t('admin_workspace')
                            when 2
                              t('manager_workspace')
                            when 3
                              t('worker_workspace')
                            end
                          %>

                        </option>
                     <%
                        end
                     %>
                       </select>
                     <%
                        end
                     %>
                     <%= link_to t('.sign_out'), destroy_user_session_path, :method => :delete %>
                 <% else %>
                     <%= link_to t('.register'), new_user_registration_path %> or <%= link_to 'Sign in', new_user_session_path %>
                 <% end %>
               </div>
            </ul>
          </div>
        </div>
      </div>
    </div>

    <!--Barra 1 y dos-->
    <div id="sg_global_nav" class="">
        <div class="top_bar" id="ext-gen449">
          <div class="nav_item spacer" id="ext-gen448"></div>
        </div>
        <!--Barra 2-->
      <div class="project_nav" id="ext-gen97">
          <div class="nav_item spacer" id="ext-gen448">
          </div>
        <% if @message then %>
            <div id="message" style="background-color: #003580; height: 40px; width: 100%; text-align: center; vertical-align: middle; color: #FFFFFF" ><%= @message %></div>
        <% end  %>
      </div>
    </div>


    <!-- Menu y contenido
    ================================================== -->
    <div class="sg_main">
      <div class="sg_page" id="sg_page_1339_1">
        <div class="contents  " id="ext-gen33">

          <%= yield %>

        </div>
      </div>
    </div>
    <%= yield :modal %>
  </body>

</html>